package com.mxdx.edu.service.impl;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.mxdx.edu.dao.CmsArticleDao;
import com.mxdx.edu.service.ICmsArticleService;

/**
 * cmsservice
 *
 * @author howie
 */
@Service
public class CmsArticleServiceImpl implements ICmsArticleService {

	@Resource
	private CmsArticleDao cmsArticleDao;


	@Override
	public List<Map<String, Object>> findListByMap(Map<String, Object> param) {
		return null;
	}

	@Override
	public Map<String, Object> findMapByMap(Map<String, Object> param) {
		List<Map<String, Object>> list = cmsArticleDao.findListByMap(param);
		if(list != null && list.size() > 0){
			return list.get(0);
		}
		return null;
	}

	@Override
	public Map<String,Object> getLastArticleInfo(String categoryId, Date createDate) {
		Map<String,Object> map = new HashMap<>();
		map.put("categoryId", categoryId);
		map.put("ltCreateDate", createDate);
		map.put("order", "DESC");
		return cmsArticleDao.findLastOrNextByMap(map);
	}

	@Override
	public Map<String,Object> getNextArticleInfo(String categoryId, Date createDate) {
		Map<String,Object> map = new HashMap<>();
		map.put("categoryId", categoryId);
		map.put("gtCreateDate", createDate);
		map.put("order", "ASC");
		return cmsArticleDao.findLastOrNextByMap(map);
	}
}
